home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1990 June / 1990-06.d64 / bas_beg 3 (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  1KB  |  27 lines

  1. 5 print"[147]":poke53280,6:poke53281,6
  2. 10 for j=54272 to 54295:poke j,0:next:rem clear sound chip
  3. 20 poke 54275,8:poke 54296,15:rem square wave, full volume, no adsr for tick
  4. 30 poke 54273,100:rem set tick pitch. try others
  5. 40 input "[147]hours";t(1):if t(1)>12 then 40
  6. 50 input "minutes";t(2):if t(2)>59 then print"[145][145][145]":goto 50
  7. 60 input "seconds";t(3):if t(3)>59 then print"[145][145][145]":goto 60
  8. 99 rem line 100 calculates pokeable values for 3 time-of-day memory registers
  9. 100 for i=1 to 3:h=int(t(i)/10):l=t(i)-10*h:t(i)=16*h+l:next
  10. 110 c=56331:rem top of 4 tod registers
  11. 120 poke c,t(1):poke c-1,t(2):poke c-2,t(3):rem fills top three registers
  12. 121 rem line 120 another way: for i=0 to 3:poke c-i,t(i+1):next
  13. 130 print "press any key to start clock."
  14. 140 get a$:if a$="" then 140
  15. 150 print "[147]"
  16. 160 poke c-3,0:rem starts clock
  17. 169 rem lines 170-240 form loop which repeatedly reads the 4 memory registers
  18. 170 h=peek(c):m=peek(c-1):s=peek(c-2):t=peek(c-3):rem reading the registers
  19. 180 c1$=chr$((16 and h)/16+48)+chr$((15 and h)+48):rem forming hours string
  20. 190 c2$=chr$((240 and m)/16+48)+chr$((15 and m)+48):rem forming minutes string
  21. 200 c3$=chr$((240 and s)/16+48)+chr$((15 and s)+48):rem forming seconds string
  22. 210 if c3$=c4$ then 230:rem if not the same, print time & skip sound subroutine
  23. 220 gosub 300:c4$=c3$:rem c3$ <> c4$, therefore sound tick, make c4$=c3$ again
  24. 230 print "time is "c1$+":"+c2$+":"+c3$+":"t"[145]":rem print time, cursor up
  25. 240 goto 170
  26. 300 poke 54276,65:poke 54276,64:return:rem turns sound on and off quickly
  27.